/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.constant.enums;

import com.comac.ins.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 对比结果类型
 *
 * @author hxloongs
 * @date 2025-01-23
 */
@AllArgsConstructor
@Getter
public enum IsfdMeshCompareResultTypeEnum {
    ADD("add", "新增"),
    REMOVE("remove", "删除"),
    MODIFIED("modified", "差异");

    private final String value;
    private final String desc;

    public static String getDescByValue(String value) {
        IsfdMeshCompareResultTypeEnum isfdMeshCompareResultTypeEnum = forValue(value);
        if (isfdMeshCompareResultTypeEnum == null) {
            return null;
        }
        return isfdMeshCompareResultTypeEnum.getDesc();
    }

    public static IsfdMeshCompareResultTypeEnum forValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (IsfdMeshCompareResultTypeEnum isfdMeshCompareResultTypeEnum : IsfdMeshCompareResultTypeEnum.values()) {
            if (isfdMeshCompareResultTypeEnum.getValue().equalsIgnoreCase(value)) {
                return isfdMeshCompareResultTypeEnum;
            }
        }
        return null;
    }

    public static IsfdMeshCompareResultTypeEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdMeshCompareResultTypeEnum isfdMeshCompareResultTypeEnum : IsfdMeshCompareResultTypeEnum.values()) {
            if (desc.equals(isfdMeshCompareResultTypeEnum.getDesc())) {
                return isfdMeshCompareResultTypeEnum;
            }
        }
        return null;
    }
}
